<%@ page import="java.util.List" %>
<%@ page import="com.foreknow.model.Guestbook" %>

<%--
  Created by IntelliJ IDEA.
  User: Ythhh
  Date: 2021/8/23
  Time: 10:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--引用JSTL标签库  taglib--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--分页用标签库--%>
<%@ taglib prefix="pager" uri="http://blog.zjjlive.net/zjjlive/tags/pager" %>
<html>
<head>
    <title>Title</title>
    <link href="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.12/dist/css/bootstrap.min.css"
          rel="stylesheet">
</head>
<body>

<div class="container">
    用户名：${sessionScope.username}
    <table class="table table-hover">
        <tr>
            <td>ID</td>
            <td>Name</td>
            <td>Phone</td>
            <td>Email</td>
            <td>Title</td>
            <td>Content</td>
            <td>CreateTime</td>
            <td>Control</td>
            <%--        </tr>--%>
            <%--        <%--%>
            <%--            //要从request获取到list集合--%>
            <%--            List<Object> list = (List<Object>) request.getAttribute("list");--%>
            <%--            for (int i = 0; i < list.size(); i++) {--%>
            <%--                Guestbook gb = (Guestbook) list.get(i);--%>
            <%--        %>--%>
            <c:forEach var="gb" items="${sessionScope.list}">
        <tr>
            <%--与Guestbook.java 中的属性一致--%>
            <td>${gb.id}</td>
            <td>${gb.name}</td>
            <td>${gb.phone}</td>
            <td>${gb.email}</td>
            <td>${gb.title}</td>
            <td>${gb.content}</td>
            <td>${gb.createdTime}</td>
            <td>
                <a href="" class="btn btn-primary">添加留言</a>
                <a href="/hungry/user/manager?id=${gb.id}&q=queryById" class="btn btn-primary">Update</a>
                <a href="/hungry/user/manager?id=${gb.id}&q=delete" class="btn btn-danger">Delete</a>
            </td>
        </tr>
        </c:forEach>
    </table>
    <div>
        <pager:pager pageNo="${sessionScope.pageNo}"
                     recordCount="${sessionScope.total}"
                     pageSize="${initParam.pageSize}" url="/hungry/user/manager?q=list"/>
    </div>
</div>
</body>
</html>
